<!--交付物列表-->
<template>
  <a-drawer
    title="交付物列表"
    :width="920"
    :visible="drawerVisible"
    :body-style="{ paddingBottom: '80px' }"
    @close="closeApplyComplete"
  >
    <task-table :table-data="tableData" :load-visible="loadingVisible" :row-selection="rowSelection"
                :customRow="rowHover" @routerSubmitDel="routerSubmitDel"
                :table-columns="tableColumns" :pagination="tablePagination" table-name="交付物列表"></task-table>
    <div
      :style="{
          position: 'absolute',
          right: 0,
          bottom: 0,
          width: '100%',
          borderTop: '1px solid #e9e9e9',
          padding: '10px 16px',
          background: '#fff',
          textAlign: 'right',
          zIndex: 1,
        }"
    >
      <a-button type="primary" @click="closeApplyComplete">
        确认
      </a-button>
    </div>
  </a-drawer>
</template>
<script>
import taskTable from "./comp/taskTable.vue";
import {getDeliverableList} from "@api/todoPage";
import _ from "lodash";
export default {
  name: "deliverableList",
  components: {taskTable},
  data() {
    return {
      drawerVisible: this.drawerVisible_p,
      tableData: [{
        "deliverable.lastVersion": "是",
        "deliverable.name": "测试交付物01",
        "deliverable.name.url": "http://plm.muxin.com/Windchill/servlet/WindchillAuthGW/wt.content.ContentHttp/viewContent/PRINT_1557992008663%E6%9C%BA%E6%A2%B0%E5%8A%A0%E5%B7%A5%E5%B7%A5%E8%89%BA%E8%BF%87%E7%A8%8B%E5%8D%A1%E7%89%87%E9%83%A8%E4%BB%B6_A4.pdf?u8&HttpOperationItem=wt.content.ApplicationData%3A986352&ofn=PRINT_1557992008663%E6%9C%BA%E6%A2%B0%E5%8A%A0%E5%B7%A5%E5%B7%A5%E8%89%BA%E8%BF%87%E7%A8%8B%E5%8D%A1%E7%89%87%E9%83%A8%E4%BB%B6_A4.pdf&ContentHolder=wt.doc.WTDocument%3A986350&forceDownload=true",
        "deliverable.oid": "OR:com.pisx.pmgt.deliverable.PIPlanDeliverable:3659775",
        "deliverable.targetStatus": "已发放C",
        "subject.name": "机械加工工艺过程卡片部件机械加工工艺过程卡片部件PRINT_1557992008663机械加工工艺过程卡片部件_A4",
      }],
      rowSelection: false,
      showEye: {},//显示交付物后的小眼睛
      tableColumns: [
        {
          title: "交付物要求",
          dataIndex: "deliverable.name",
          width: '22%',
          ellipsis: true,
          scopedSlots: {customRender: "deliverableName"}
        },
        {
          title: "交付物",
          dataIndex: "subject.name",
          width: '40%',
          ellipsis: false,
          scopedSlots: {customRender: "subjectNameNoUp"}
        },
        {
          title: "是否最新版本",
          width: '19%',
          dataIndex: "deliverable.lastVersion"
        },
        {
          title: "交付物状态",
          width: '19%',
          dataIndex: "deliverable.targetStatus"
        }
      ],
      loadingVisible: false,
      tablePagination: {
        pageSize: 10,
      }
    }
  },
  props: {
    drawerVisible_p: {
      type: Boolean,
      default: false
    },
    oid: {
      type: String,
      default: 'OR:com.pisx.pmgt.project.PIProject:1080235'
    },//任务id
  },
  computed: {},
  watch: {
    drawerVisible_p(val) {
    },
  },
  mounted() {
    this.getDeliverableData()
  },
  methods: {
    //关闭抽屉
    closeApplyComplete() {
      this.$emit('closeDraw')
    },
    //获取交付物列表
    //获取交付物表格数据
    getDeliverableData() {
      // console.log('获取交付物表格数据--oid:', this.oid)
      let parms = {
        // oid: "OR:com.pisx.pmgt.plan.PIPlanActivity:1364663"
        oid: this.oid
      }
      getDeliverableList(parms).then(res => {
          this.loadingVisible = true
          this.tableData = []
          // console.log(res)
          if (res && res.status === 200) {
            if (res.data && res.data.success) {
              if (res.data.data && res.data.data.length > 0) {
                this.tableData = res.data.data
                this.loadingVisible = false
              } else {
                this.tableData = []
                this.loadingVisible = false
              }
            } else {
              this.tableData = []
              this.loadingVisible = false
              this.$message.error(res.data.message)
            }
          } else {
            this.$message.error('接口失败')
          }
        }
      )
    },
    //行移入显示小眼睛
    rowHover(record, index) {
      // const _this = this
      return {
        on: {
          mouseenter: (event) => {
            this.showEye = record
          },  // 鼠标移入行
          mouseleave: (event) => {
            this.showEye = {}
          },
        },
      };
    },
    //交付物预览
    routerSubmitDel(val){
      window.open(val['deliverable.name.url'])
    }
  },
}
</script>
<style scoped lang="less">
.applyDraw_temp {
  /deep/ .ant-row {
    margin-bottom: 10px;
  }
  /deep/ .ant-drawer-content-wrapper {
    width: 520px !important;
  }
}
</style>